package com.teyao.teyao_back.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.teyao.teyao_back.entity.Dict;
import com.teyao.teyao_back.entity.ResponseMessage;
import com.teyao.teyao_back.entity.Result;
import com.teyao.teyao_back.service.DictService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("/dict")
public class DictController {
    @Autowired
    private DictService dictService;

    @GetMapping("/selectStatus")
    public ResponseMessage selectStatus() {
        return dictService.selectStatus();
    }


    @GetMapping("/selectClass")
    public ResponseMessage selectClass() {

        return dictService.selectClass();

    }

    @GetMapping("/selectType")
    public ResponseMessage selectType() {
        return dictService.selectType();
    }


    //输出全部表(梁宏宇)
    @GetMapping("/intoAll")
    public List<Dict> intoAll() {
        return dictService.list();
    }

    //分页输出（梁宏宇）
    @GetMapping("/list")
    public Result list(Dict dict, Integer pageSize, long current) {
        return dictService.getList(dict, pageSize, current);
    }

    //删除数据字典列表(梁宏宇)
    @PostMapping("/deleteList")
    public ResponseMessage deleteList(Integer dictId) {
        return dictService.deleteList(dictId);
    }

    //修改数据字典列表
    @PostMapping("/updateList")
    public ResponseMessage updateList(Integer dictId, Dict dict) {
        return dictService.updateList(dictId, dict);
    }

    //添加数据字典列表
    @PostMapping("/insertList")
    public ResponseMessage insertList(Dict dict) {
        return dictService.insertList(dict);
    }

    //詹
    @GetMapping("/listBySuperId")
    public List<Dict> list() {
        QueryWrapper<Dict> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("super_id", 1);
        return dictService.list(queryWrapper);
    }
}
